package com.pug.zixun.config.mvc;

import com.pug.zixun.config.interceptor.PassportLoginInterceptor;
import com.pug.zixun.config.interceptor.PassportLogoutInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description:
 * @Author: WengYu
 * @CreateTime: 2022/05/19 14:53
 */

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private PassportLogoutInterceptor passportLogoutInterceptor;
    @Autowired
    private PassportLoginInterceptor passportLoginInterceptor ;

    /**
     * 拦截器注册
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 下线拦截器
        registry.addInterceptor(passportLogoutInterceptor).addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/login/**");
        // 登陆拦截器
        registry.addInterceptor(passportLoginInterceptor).addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/login/**");
    }
}
